package com.ftg.learn.sys.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ftg.learn.comm.entity.sys.User;
import com.ftg.learn.sys.user.vo.UserEmpVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author kangjx
 * @createTime 2022/10/5
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("select * from sys_user")
    @Results({
            @Result(property = "account",column = "u_account"),
            @Result(property = "emp",one = @One(select = "com.ftg.learn.mapper.DictionaryMapper.selectById"),column = "e_id")
            }
    )
    public List<UserEmpVo> showUserEmp();

    /**
     * 解冻方法
     * @param id 编号
     */
    @Update("update sys_user set is_deleted = 0, gmc_update=now() where id = #{id}")
    void unFreezeUserMapper(@Param("id") Integer id);

    /**
     * 重围密码
     * $ # 区别
     * @param password  重置以后的密码
     * @param id        编号
     * @return
     */
    @Update("update sys_user set u_password = #{password}, gmc_update=now() where id = #{id}")
    boolean resetPasword(@Param("password") String password, @Param("id") Integer id);
}
